# Makefile for Spring Boot application with Docker support

# Variables
IMAGE_NAME = hello-svc
IMAGE_TAG = latest
DOCKER_REGISTRY = YOUR_DOCKER_HUB/dev/zhoujw


# Default goal
all: build

# Build the Spring Boot application
build:
	mvn clean package -DskipTests -U -s ./ci/settings.xml

# Build the Docker image
docker-build:
	docker build -t $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) -f ./ci/DockerfileLocal .

# Push the Docker image to the registry
docker-push: docker-build
	docker push $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)

# Run the Docker container locally
docker-run: docker-build
	docker run -p 8080:8080 $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)

# Clean up
clean:
	rm -rf target/
	docker rmi $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) || true

# Run tests
test:
	mvn test

.PHONY: all build docker-build docker-push docker-run clean test